<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Doit extends CI_Controller {
	public function index()
	{
		$this->load->library('table');

		$data['query'] = $this->db->query("SELECT * FROM do_items where state = '00A' order by id desc")->result_array() ;
		
		$this->load->view('do/do_view',$data);
	}
	
	public function add()
	{
		$data = array(
			'content' => $_POST['content']
		);
		$this->db->insert('do_items', $data);
		//$this->load->view('do/do_view',$data);
		redirect('/doit', 'refresh');
	}
	
	public function delete()
	{
		$this->db->where('id', $this->uri->segment(3));
		$this->db->delete('do_items');
		redirect('/doit', 'refresh');
	}
	
	public function archive()
	{
		$data = array(
			'state' => '00F'
		);
		$this->db->where('id', $this->uri->segment(3));
		$this->db->update('do_items', $data);
		redirect('/doit', 'refresh');
	}
}